package com.xyd.util;

import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

/**
 * 类描述：json化返回工具类
 *
 * @author 张吉哲
 * @date 2021/1/11 11:55
 */
public class JsonUtil {

  public static void toJson(HttpServletResponse response, Object obj) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    response.setContentType("application/json;charset=utf-8");
    mapper.writeValue(response.getOutputStream(), obj);
  }
}
